;;;Place text on a line.  (uses GETSTYLE USTR MKLAYR)
;;;
;;;	AUTHOR: HENRY C. FRANCIS
;;;		425 N. ASHE ST.
;;;		SOUTHERN PINES, NC 28387
;;;              
;;;		All rights reserved without prejudice.
;;;	Copyright:	4-7-95
;;;	Edited:		10-6-2005
;;;
(DEFUN C:TXONL ( / pt1 bkp1b bkp1m bkp1r bkp1l bkp1a bkp2b bkp2m bkp2r bkp2l
bkp2a bkp3b bkp3m bkp3r bkp3l bkp3a templ selpt tstpt sel1 oldcl clayr)
;(c:svlayr)
;(setq dimsc (getvar"dimscale"))
(if ustr nil (load"ustr" "\nFile USTR.LSP not loaded! "))
(if dimscl nil (load"dimscl" "\nFile DIMSCL.LSP not loaded! "))
(dimscl)
(if getstyle nil (load"getstyle" "\nFile GETSTYLE.LSP not loaded! "))
(getstyle "A")
(setq thts (ustr 1 "\n\"Leroy Template Size\" or Standard(=110) " (if thts thts "Standard")nil))
  (cond
    ((or(eq (substr thts 1 1)"S")(eq (substr thts 1 1)"s"))
      (setq colr "6"))
    ((<=(atoi thts)80)
      (setq colr "1"))
    ((<=(atoi thts)125)
      (setq colr "6"))
    ((<(atoi thts)200)
      (setq colr "4"))
    ((>=(atoi thts)200)
      (setq colr "2"))
    (thts
      (setq colr "6"))
  );cond
(princ "\nSelect Line: ")
(while
  (and
    (setq selpt (grread))
    (or
      (eq(nth 0 selpt)3)
      (eq(nth 0 selpt)12)
    );or
  );and
  (setq tstpt (nth 1 selpt))
  (if
    (and
      (setq sel1 (nentselp "" tstpt))
      (or
        (eq "LINE" (cdr(assoc 0(entget(car sel1)))))
        (eq "VERTEX" (cdr(assoc 0(entget(car sel1)))))
      );or
    );and
  (if(or(eq "LINE" (cdr(assoc 0(entget(car sel1)))))(eq "VERTEX" (cdr(assoc 0(entget(car sel1))))))
  (progn
    (if sytxt
      (setq txstr sytxt sytxt nil)
      (setq txstr (ustr 1 "Enter text" (if txstr txstr "") "T"))
    );if
;    (setq oldcl clayr
;          clayr (cdr(assoc 8(entget(car sel1))))
;    );setq
;    (setvar"clayer" clayr)
;    (if (clnmstd)
;      (progn
;        (setq mjrg (substr clayr 1 1)
;              llt "-"
;              prod (substr clayr 3 4)
;              modf "NOTE"
;        );setq
;        (c:mklayr)
;      );progn
;      (progn
;        (setq clayr oldcl)
;        (c:slent)
;      );progn
;    );if
    (setq endp1 (trans(cdr(assoc 10(entget(car sel1)))) 0 1))
    (if (eq "LINE" (cdr(assoc 0(entget(car sel1)))))
      (setq endp2 (trans(cdr(assoc 11(entget(car sel1)))) 0 1))
      (setq endp2 (trans(cdr(assoc 10(entget(entnext(car sel1))))) 0 1))
    );if
    (setq lang (angle endp1 endp2)
          chkang (+ lang (getvar"viewtwist")))
    (if (and(> chkang 1.868)(< chkang 5.01))
      (setq tang (angtos (+ pi lang) 1 4)
            osang (+(* pi 0.5) lang))
      (setq tang (angtos lang 1 4)
            osang (+(* pi 1.5) lang))
    );if
;    (setq txtht (*(/(atoi thts)1000.00)dimsc))
  (if(or(eq (substr thts 1 1) "S")(eq (substr thts 1 1) "s"))
    (setq txtht (* 0.110 dimsc))
    (setq txtht (*(*(atoi thts)0.001) dimsc))
  );if
    (setq pt1
      (polar endp1 lang
        (distance
          (list(car endp1)(cadr endp1))
          (list(car(last sel1))(cadr(last sel1)))
        )
      )
    )
    (setq pt1 (list (car pt1)(cadr pt1)0))
    (command ".text" "j" "mc" pt1 txtht tang txstr)
    (princ "\nSelect Line: ")
  );progn
  (princ "\nNot a Line or a Polyline! ")
  );if
  );if
);while
;(c:rslayr)
(getstyle "")
(setq sytxt nil)
(princ)
);defun
